home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / autose1g / contxtid.bas < prev    next >
Encoding:
BASIC Source File  |  1999-02-28  |  9.8 KB  |  215 lines

  1. Attribute VB_Name = "ContextIDs"
  2. Option Explicit
  3. '=====================================================================
  4. '                  Copyright 1993 by Fred Bunn, All rights reserved
  5. '
  6. '
  7. 'This source code may not be distributed in part or as a whole without
  8. 'express written permission from Fred Bunn and Teletech Systems.
  9. '=====================================================================
  10. '
  11. 'This source code contains the following routines:
  12. '  o SetAppHelp() 'Called in the main Form_Load event to register your
  13. '                 'program with WINHELP.EXE
  14. '  o QuitHelp()    'Deregisters your program with WINHELP.EXE. Should
  15. '                  'be called in your main Form_Unload event
  16. '  o ShowHelpTopic(Topicnum) 'Brings up context sensitive help based on
  17. '                  'any of the following CONTEXT IDs
  18. '  o ShowContents  'Displays the startup topic
  19. '********** Shameless Plug <g> **********
  20. 'The Standard and Professional editions of VB HelpWriter 
  21. ' also include the following routines to add sizzle to your
  22. ' helpfile presentation...
  23. '  o HelpWindowSize(x,y,dx,dy) ' Position help window in a screen
  24. '                              ' independent manner
  25. '  o SearchHelp()  'Brings up the windows help KEYWORD SEARCH dialog box
  26. '***********************************************************************
  27. '
  28. '=====================================================================
  29. 'List of Context IDs for <4000>
  30. '=====================================================================
  31. Global Const Hlp_Launching_Ships = 50    'Main Help Window
  32. Global Const Hlp_Planet_Management = 20    'Main Help Window
  33. Global Const Hlp_Research = 30    'Main Help Window
  34. Global Const Hlp_Combat = 40    'Main Help Window
  35. Global Const Hlp_Overview = 10    'Main Help Window
  36. Global Const Hlp_CreditsxOther_Information = 60    'Main Help Window
  37. Global Const Hlp_Registration = 80    'Main Help Window
  38. Global Const Hlp_Beginning_a = 90    'Main Help Window
  39. Global Const Hlp_Playing_the = 100    'Main Help Window
  40. Global Const Hlp_LoadingxSaving_Games = 110    'Main Help Window
  41. Global Const Hlp_SendingxReceiving_Messages = 120    'Main Help Window
  42. Global Const Hlp_BioChemical_Warfare = 130    'Main Help Window
  43. Global Const Hlp_Sabotage_Missions = 140    'Main Help Window
  44. Global Const Hlp_Combat_Overview = 150    'Main Help Window
  45. Global Const Hlp_Getting_Help = 160    'Main Help Window
  46. Global Const planet_management_frame =  170
  47. Global Const Cloaking_Device =  180
  48. Global Const Combat_Strength =  190
  49. Global Const Landscape_View =  200
  50. Global Const sending_the_turn_by_email =  210
  51. Global Const Melnikons =  220
  52. Global Const Sabotage_Missions =  230
  53. Global Const Repairing_Industry =  240
  54. Global Const starting_coordinates =  250
  55. '=====================================================================
  56. '
  57. '
  58. '  Help engine section.
  59.  
  60. ' Commands to pass WinHelp()
  61. Global Const HELP_CONTEXT = &H1 '  Display topic in ulTopic
  62. Global Const HELP_QUIT = &H2    '  Terminate help
  63. Global Const HELP_INDEX = &H3   '  Display index
  64. Global Const HELP_HELPONHELP = &H4      '  Display help on using help
  65. Global Const HELP_SETINDEX = &H5        '  Set the current Index for multi index help
  66. Global Const HELP_KEY = &H101           '  Display topic for keyword in offabData
  67. Global Const HELP_MULTIKEY = &H201
  68. Global Const HELP_CONTENTS = &H3     ' Display Help for a particular topic
  69. Global Const HELP_SETCONTENTS = &H5  ' Display Help contents topic
  70. Global Const HELP_CONTEXTPOPUP = &H8 ' Display Help topic in popup window
  71. Global Const HELP_FORCEFILE = &H9    ' Ensure correct Help file is displayed
  72. Global Const HELP_COMMAND = &H102    ' Execute Help macro
  73. Global Const HELP_PARTIALKEY = &H105 ' Display topic found in keyword list
  74. Global Const HELP_SETWINPOS = &H203  ' Display and position Help window
  75.  
  76. #If Win32 Then
  77.     Type HELPWININFO
  78.       wStructSize As Long
  79.       X As Long
  80.       Y As Long
  81.       dX As Long
  82.       dY As Long
  83.       wMax As Long
  84.       rgChMember As String * 2
  85.     End Type
  86.     Declare Function WinHelp Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long
  87.     Declare Function WinHelpByInfo Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, dwData As HELPWININFO) As Long
  88.     Declare Function WinHelpByStr Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData$) As Long
  89.     Declare Function WinHelpByNum Lib "User32" Alias "WinHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData&) As Long
  90.     Dim m_hWndMainWindow as Long ' hWnd to tell WINHELP the helpfile owner
  91.  
  92. #Else
  93.     Type HELPWININFO
  94.         wStructSize As Integer
  95.         X As Integer
  96.         Y As Integer
  97.         dX As Integer
  98.         dY As Integer
  99.         wMax As Integer
  100.         rgChMember As String * 2
  101.     End Type
  102.     Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData As Any) As Integer
  103.     Declare Function WinHelpByInfo Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, dwData As HELPWININFO) As Integer
  104.     Declare Function WinHelpByStr Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData$) As Integer
  105.     Declare Function WinHelpByNum Lib "User" Alias "WinHelp" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, ByVal dwData&) As Integer
  106.     Dim m_hWndMainWindow as Integer ' hWnd to tell WINHELP the helpfile owner
  107.  
  108. #End If
  109. Dim MainWindowInfo as HELPWININFO
  110. Sub SetAppHelp (ByVal hWndMainWindow)
  111. '=====================================================================
  112. 'To use these subroutines to access WINHELP, you need to add
  113. 'at least this one subroutine call to your code
  114. '     o  In the Form_Load event of your main Form enter:
  115. '        Call SetAppHelp(Me.hWnd) 'To setup helpfile variables
  116. '         (If you are not interested in keyword searching or context
  117. '         sensitive help, this is the only call you need to make!)
  118. '=====================================================================
  119.     m_hWndMainWindow = hWndMainWindow
  120.     If Right$(Trim$(App.Path),1) = "\" then
  121.         App.HelpFile = App.Path + "4000.HLP"
  122.     else
  123.         App.HelpFile = App.Path + "\4000.HLP"
  124.     end if
  125. #If Win32 Then
  126.     MainWindowInfo.wStructSize = 26
  127. #Else
  128.     MainWindowInfo.wStructSize = 14
  129. #End If 
  130.     MainWindowInfo.X=256
  131.     MainWindowInfo.Y=256
  132.     MainWindowInfo.dX=512
  133.     MainWindowInfo.dY=512
  134.     MainWindowInfo.rgChMember=Chr$(0)+Chr$(0)
  135. End Sub
  136. Sub QuitHelp ()
  137.     Dim Result as Variant
  138.     Result = WinHelp(m_hWndMainWindow, App.HelpFile, HELP_QUIT, Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0))
  139. End Sub
  140. Sub ShowHelpTopic (ByVal ContextID As Long)
  141. '=====================================================================
  142. '  FOR CONTEXT SENSITIVE HELP IN RESPONSE TO A COMMAND BUTTON ...
  143. '=====================================================================
  144. '     o   For 'Help button' controls, you can call:
  145. '         Call ShowHelpTopic(<any Hlpxxx entry above>)
  146. '=====================================================================
  147. '  TO ADD FORM LEVEL CONTEXT SENSITIVE HELP...
  148. '=====================================================================
  149. '     o  For FORM level context sensetive help, you should set each 
  150. '        Me.HelpContext=<any Hlp_xxx entry above>
  151. '
  152.     Dim Result as Variant
  153.  
  154.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXT, Clng(ContextID))
  155.  
  156. End Sub
  157. Sub ShowHelpTopic2 (ByVal ContextID As Long)
  158. '=====================================================================
  159. '  DISPLAY CONTEXT SENSITIVE HELP IN WINDOW 2 ...
  160. '=====================================================================
  161. '     o   For 'Help button' controls, you can call:
  162. '         Call ShowHelpTopic2(<any Hlpxxx entry above>)
  163. '
  164.     Dim Result as Variant
  165.  
  166.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile &">HlpWnd02", HELP_CONTEXT, Clng(ContextID))
  167.  
  168. End Sub
  169. Sub ShowHelpTopic3 (ByVal ContextID As Long)
  170. '=====================================================================
  171. '  DISPLAY CONTEXT SENSITIVE HELP IN WINDOW 3 ...
  172. '=====================================================================
  173. '     o   For 'Help button' controls, you can call:
  174. '         Call ShowHelpTopic3(<any Hlpxxx entry above>)
  175. '
  176.     Dim Result as Variant
  177.  
  178.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile &">HlpWnd03", HELP_CONTEXT, Clng(ContextID))
  179.  
  180. End Sub
  181. Sub ShowGlossary ()
  182.     Dim Result as Variant
  183.  
  184.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXT, Clng(64000))
  185.  
  186. End Sub
  187. Sub ShowPopupHelp (ByVal ContextID As Long)
  188. '=====================================================================
  189. '  FOR POPUP HELP IN RESPONSE TO A COMMAND BUTTON ...
  190. '=====================================================================
  191.     Dim Result as Variant
  192.  
  193.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTEXTPOPUP, Clng(ContextID))
  194.  
  195. End Sub
  196. Sub DoHelpMacro (ByVal MacroString As String)
  197. '=====================================================================
  198. '  FOR POPUP HELP IN RESPONSE TO A COMMAND BUTTON ...
  199. '=====================================================================
  200.     Dim Result as Variant
  201.  
  202.     Result = WinHelpByStr(m_hWndMainWindow, APP.HelpFile, HELP_COMMAND, ByVal(Macrostring))
  203.  
  204. End Sub
  205. Sub ShowHelpContents ()
  206. '=====================================================================
  207. '  DISPLY HELP STARTUP TOPIC IN RESPONSE TO A COMMAND BUTTON or MENU ...
  208. '=====================================================================
  209. '
  210.     Dim Result as Variant
  211.  
  212.     Result = WinHelpByNum(m_hWndMainWindow, APP.HelpFile, HELP_CONTENTS, Clng(0))
  213.  
  214. End Sub
  215.